package com.bringway.p2p.controller;


import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.sf.json.JSONObject;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.bringway.framework.controller.JsonController;
import com.bringway.framework.util.RequestUtils;
import com.bringway.p2p.service.BxxService;
/**
 * 
 * @author qjy
 * @version 创建时间：2016年06月14日 上午13:15:42
 * @功能：异常查询
 */
@Controller
@RequestMapping("/bxx")
public class BxxController  extends JsonController {
	
	@Autowired
	private BxxService bxxService;
	/**
	 * 
	 * @param request
	 * @param response 查询数据
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/queryBxxList")
	public ModelAndView queryBxxList(HttpServletRequest request,HttpServletResponse response) throws Exception{
		JSONObject result = new JSONObject();
		JSONObject params = new JSONObject();
		Integer start = RequestUtils.getIntParameter(request, "start");
		Integer limit = RequestUtils.getIntParameter(request, "limit");
		Integer page = RequestUtils.getIntParameter(request, "page");//新版本,传参
		String zqid= RequestUtils.getStringParameter(request, "zqid");
		String xmt= RequestUtils.getStringParameter(request, "xmt");
		String zt= RequestUtils.getStringParameter(request, "zt");
		if (null!=page) {//新版本,传参
			start=(page-1)*limit;
		}
		params.put("start", start);
		params.put("limit", limit);
		params.put("zqid", zqid);
		params.put("xmt", xmt);
		params.put("zt", zt);
		List<Map<String, Object>> list = bxxService.queryBxxList(params);
	   int count = bxxService.queryBxxcount(params);
		result.put("data", list);	
		result.put("total", count);
		if (null!=page) {//新版本,传参
			int totalPage=count%limit==0?count/limit:count/limit+1;
			result.put("totalPage", totalPage);
		}
		serialize(request,response,result);
		return null;
	}
	

	
	
}
